package org.java.auth.controller;

import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;

@RestController
@RequestMapping("user-info")
public class UserInfoController {

    @GetMapping
    //如果user-center服务已经配置好资源服务，那么得到的Principal参数就是用户服务
    public Principal get(@AuthenticationPrincipal OAuth2Authentication principal){
        System.out.println(principal);
        return principal;
    }
}
